##本功能只扫描所有视频列表
##获取视频列表的接口https://om0813.zw7gmc49.work/api/station/getStationMore?stationId=13&pageSize=10&page=3&sortType=1&cartoon=true&_t=1756456891776
##需要新建数据表,字段根据animate_list.json
from 核心.配置文件 import settings
from 核心.解密数据 import vp
from 核心.公共函数 import comm
from 核心.数据操作 import MySQLCRUD
import requests, json, time


class ScanAnimate:
    ##初始化
    def __init__(self):
        self.web_url = settings.BASE_URL
        self.comm = comm

    ##扫描章节图片
    def scan_animate_page(self):
        try:
            current_timestamp = int(time.time() * 1000)
            url = f"{self.web_url}/api/station/getStationMore?stationId=243&pageSize=10&page=3&sortType=1&cartoon=true&_t={current_timestamp}"
            response = self.comm.get_resp(url)

            if not response or response.status_code != 200:
                error_msg = f"HTTP请求失败: {response.status_code if response else 'No response'}"
                print(f"✗ {error_msg}")
                return False, error_msg

            response_data = response.json()
            images_data = vp(response_data['encData'])
            print(f"{images_data}")
            ##保存到数据库

        except json.JSONDecodeError as json_error:
            error_msg = f"JSON解析失败: {json_error}"
            print(f"✗ {error_msg}")
            return False, error_msg
        except Exception as e:
            error_msg = f"扫描漫画图片失败: {e}"
            print(f"✗ {error_msg}")
            return False, error_msg


if __name__ == "__main__":
    scan_images = ScanAnimate()
    scan_images.scan_animate_page()
